package com.yz.jdd.network;


import com.yz.jdd.network.request.PayParams;
import com.yz.jdd.network.request.Request_AppLimitSetting;
import com.yz.jdd.network.request.Request_CancelOrderSetting;
import com.yz.jdd.network.request.Request_CloseOrder;
import com.yz.jdd.network.request.Request_Magic;
import com.yz.jdd.network.request.Request_OrderLiuShuiList;
import com.yz.jdd.network.request.Request_OrderTotalList;
import com.yz.jdd.network.request.Request_PayShopInfo;
import com.yz.jdd.network.request.Request_PayStatus;
import com.yz.jdd.network.request.Request_QecodeManage_listNew;
import com.yz.jdd.network.request.Request_SetShopPay;
import com.yz.jdd.network.request.Request_Status;
import com.yz.jdd.network.request.Request_Update;
import com.yz.jdd.network.request.Request_UserLogin;
import com.yz.jdd.network.request.Request_UserRegister;
import com.yz.jdd.network.request.Request_shopList;
import com.yz.jdd.network.request.Request_switchLimitationSetting;
import com.yz.jdd.network.request.Request_deviceQuery;
import com.yz.jdd.network.request.Request_upgrade;
import com.yz.jdd.network.request.Request_userSwitchSetting;
import com.yz.jdd.network.request.Requset_DeviceLogin;
import com.yz.jdd.network.request.Requset_usercenter;

import java.util.List;
import java.util.Map;

import retrofit2.http.QueryMap;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


/**
 * Created by cc on 2017/1/5.
 */

public class NetWorkRequset {
    public static void deviceLogin(Requset_DeviceLogin request_base,Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doDeviceLogin(request_base)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }

    public static void userLogin(Subscriber subscriber, Request_UserLogin request_base) {
        RetrofitUtils.getApiObservable().doUserLogin(request_base)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 验证原密码
     *
     * @param request_verifyPwd
     * @param subscriber
     */
    public static void doVerifyPwd(Requset_usercenter request_verifyPwd, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doVerifyPwd(request_verifyPwd)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 验证 验证码
     *
     * @param requset_usercenter
     * @param subscriber
     */
    public static void verifyCode(Requset_usercenter requset_usercenter, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().verifyCode(requset_usercenter)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取验证码，修改手机号
     *
     * @param requset_sendVerifyCode
     * @param subscriber
     */
    public static void sendVerifyCodeModifyPhone(Requset_usercenter requset_sendVerifyCode, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().sendVerifyCodeModifyPhone(requset_sendVerifyCode)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取验证码,重置密码
     *
     * @param requset_sendVerifyCode
     * @param subscriber
     */
    public static void sendVerifyCodeResetPWD(Requset_usercenter requset_sendVerifyCode, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().sendVerifyCodeResetPWD(requset_sendVerifyCode)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 修改手机号
     *
     * @param requset_usercenter
     * @param subscriber
     */
    public static void modifyPhone(Requset_usercenter requset_usercenter, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().modifyPhone(requset_usercenter)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 修改密码
     *
     * @param password
     * @param subscriber
     */
    public static void doModifyPwd(Requset_usercenter password, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doModifyPwd(password)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 重置，密码
     *
     * @param requset
     * @param subscriber
     */
    public static void doResetPwd(Requset_usercenter requset, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doResetPwd(requset)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 检查版本升级
     *
     * @param request_upgrade
     * @param subscriber
     */
    public static void doUpgrade(Request_upgrade request_upgrade, Subscriber subscriber) {

        RetrofitUtils.getApiObservable().doUpgrade(request_upgrade)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }

    /**
     * 获取权限
     *
     * @param subscriber
     */
    public static void doGetAccess(Subscriber subscriber) {

        RetrofitUtils.getApiObservable().doGetAccess()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取权限
     *
     * @param subscriber
     */
    public static void doUpdate(Request_Update request_update, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doUpdate(request_update)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 联网取
     *
     * @param fileUrl
     * @return
     */
    public static Observable downloadH5zip(String fileUrl) {
        return RetrofitUtils.getApiObservable().downloadH5zip(fileUrl);
    }

    /**
     * @param request_userLogin
     * @param subscriber        绑定接口，请求参数和用户登录接口一样，密码用户名传空、增加phoneNum(手机号)、veryCode(验证码)
     *                          返回值和用户登录接口一致
     */
    public static void doBindLogin(Request_UserLogin request_userLogin, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doBindLogin(request_userLogin)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 绑定手机号 验证码接口
     *
     * @param requset_usercenter
     * @param subscriber
     */
    public static void doGetBindVerifyCode(Requset_usercenter requset_usercenter, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doBindVerifyCode(requset_usercenter)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取sign
     *
     * @param subscriber
     */
    public static void doJoinLogin(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doJoinLogin()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 验证码接口
     *
     * @param subscriber mobile
     */
    public static void doSendVerify(Request_UserLogin request_userLogin, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doSendVerify(request_userLogin)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 用户注册接口
     *
     * @param subscriber mobile
     */
    public static void doRegister(Request_UserRegister request_userRegister, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doRegister(request_userRegister)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取订单列表
     *
     * @param subscriber
     */
    public static void doOrderList(Subscriber subscriber, Request_OrderTotalList request_orderTotalList) {

        RetrofitUtils.getApiObservable().doOrderList(request_orderTotalList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取收银订单汇总列表
     *
     * @param subscriber
     */
    public static void doOrderTotalList(Subscriber subscriber, Request_OrderTotalList request_orderTotalList) {

        RetrofitUtils.getApiObservable().doOrderTotalList(request_orderTotalList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }
//    /**
//     *收银订单汇总列表 - 筛选
//     *
//     * @param subscriber
//     */
//    public static void doChoiceTotal(Subscriber subscriber, Request_OrderTotalList request_orderTotalList) {
//
//        RetrofitUtils.getApiObservable().doChoiceTotal(request_orderTotalList)
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(subscriber);
//    }

    /**
     * 获取收银订单汇总列表- 流水列表明细
     *
     * @param subscriber
     */
    public static void getLiuShuiList(Subscriber subscriber, Request_OrderLiuShuiList request_orderLiuShuiList) {

        RetrofitUtils.getApiObservable().getLiuShuiList(request_orderLiuShuiList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取收银订单汇总列表- 筛选
     *
     * @param subscriber
     */
    public static void doOrderLiuShuiList(Subscriber subscriber, Request_OrderLiuShuiList request_orderLiuShuiList) {

        RetrofitUtils.getApiObservable().doOrderLiuShuiList(request_orderLiuShuiList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取收银订单汇总列表- 流水明细
     *
     * @param subscriber
     */
    public static void doGetOrderTranscationParam(Subscriber subscriber, Map<String, String> params) {

        RetrofitUtils.getApiObservable().doGetOrderTranscationParam(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 初始化今日数据
     *
     * @param subscriber
     */
    public static void doQueryTodayTradeReportData(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doQueryTodayTradeReportData()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取用户信息
     *
     * @param subscriber
     */
    public static void doInfo(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doInfo()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取boss账号创建时间，时间筛选
     *
     * @param subscriber
     */
    public static void doBossAccountTime(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doBossAccount()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取门店列表
     *
     * @param subscriber
     */
    public static void doShoplist(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().doShoplist()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取可以支付的门店列表
     *
     * @param subscriber
     */
    public static void getShopSelectForPay(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getShopSelectForPay()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取登录账号下是否有门店开通小程序套餐 的门店
     * @param subscriber
     */
    public static void getShopSelectForMarket(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getShopSelectForMarket()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }



    /**
     * 是否已经同意去口碑
     */

    public static void doCheckMoveKoubei(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().checkMoveKoubei()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 同意去口碑
     */
    public static void doConfirmMoveKoubei(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().confirmMoveKoubei()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取未读消息数量
     */
    public static void doMsgCount(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getMsgCount()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取订单筛选条件
     */
    public static void doOrderCondition(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getOrderCondition()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 蓝海广告位展示
     *
     * @param subscriber
     */
    public static void getAdsLanhaiShowJudge(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getAdsLanhaiShowJudge()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 语音播报设置查询
     *
     * @param subscriber
     */
    public static void getVoiceStatus(Subscriber subscriber) {
        RetrofitUtils.getApiObservable().getVoiceStatus()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 语音播报设置接口
     *
     * @param subscriber
     */
    public static void setVoiceSetting(Map<String, Object> request_voiceSetting, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().setVoiceSetting(request_voiceSetting)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 防逃单语音播报设置
     *
     * @param subscriber
     */
    public static void setCancelOrderSetting(Request_Status status, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().setCancelOrderSetting(status)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取二维码列表
     * ?shopId=${this.shopId}&currentPage=${this.pageIndex}&pageSize=${this.pageSize}
     *
     * @param subscriber
     */
    public static void getQrCodeList(Request_QecodeManage_listNew params, Subscriber subscriber) {

        RetrofitUtils.getApiObservable().qecodeManage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 设置播报码
     *
     * @param request
     * @param subscriber
     */
    public static void setAppLimitSetting(Request_AppLimitSetting request, Subscriber subscriber) {
        RetrofitUtils.getApiObservable().setAppLimitSetting(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * =========================================扫码支付==============================================
     * 获取支付订单状态
     *
     * @param request_payStatus
     * @param callback
     * @return
     */
    public static Subscription getPayStatus(Request_PayStatus request_payStatus, ApiCallback callback) {
        return RetrofitUtils.getApiObservable().doGetPayStatus(request_payStatus)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(callback);


    }


    /**
     * 主扫码支付通用
     *
     * @param param
     * @param callback
     * @return
     */

    public static Subscription doScanpay(PayParams param, ApiCallback callback) {

        return RetrofitUtils.getApiObservable().doScanpay(param)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(callback);

    }

    /**
     * 支付宝支付/储值
     *
     * @param param
     * @param callback
     * @return
     */

    public static Subscription doAliPay(PayParams param, ApiCallback callback) {

        return RetrofitUtils.getApiObservable().doAliPay(param)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(callback);

    }

    /**
     * 微信支付
     *
     * @param param
     * @param callback
     * @return
     */

    public static Subscription doWechatPay(PayParams param, ApiCallback callback) {

        return RetrofitUtils.getApiObservable().doWechatPay(param)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(callback);
    }

    /**
     * 二维码支付
     *
     * @param param
     * @param callback
     * @return
     */

    public static Subscription doQrPay(PayParams param, ApiCallback callback) {
        return RetrofitUtils.getApiObservable().doQrPay(param)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(callback);
    }

    /**
     * 查询充值送活动列表
     *
     * @param callback
     */
    public static void doQueryBalTemp(ApiCallback callback) {
         RetrofitUtils.getApiObservable().doQueryBalTemp().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(callback);
    }


    /**
     * 关闭订单
     *
     * @param request_closeOrder
     * @param apiCallback
     */
    public static void closeOrder(Request_CloseOrder request_closeOrder, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .closeOrder(request_closeOrder)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * 发送验证码
     * @param params
     * @param apiCallback
     */
    public static void sendMagicVerifyCode(Map<String, String> params, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .sendMagicVerifyCode(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * ml
     * @param request
     * @param apiCallback
     */
    public static void magicLogin(Request_UserLogin request, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .magicLogin(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * 获取花呗分期信息
     * @param map shopId
     * @param apiCallback
     */
    public static void queryHuaBeiInfo(Map<String, String> map, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .queryHuaBeiInfo(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * 查询默认支付门店
     * @param request_payShopInfo
     * @param apiCallback
     */
    public static void getPayShopInfo(Request_PayShopInfo request_payShopInfo, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .getPayShopInfo(request_payShopInfo)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * 设置默认支付门店
     * @param request_setShopPay
     * @param apiCallback
     */
    public static void saveAndUpdateCommonConfig(Request_SetShopPay request_setShopPay, ApiCallback apiCallback) {
        RetrofitUtils.getApiObservable()
                .saveAndUpdateCommonConfig(request_setShopPay)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiCallback);
    }

    /**
     * 获取bd 信息
     * @param mySubscriber
     */
    public static void queryBdInfo(MySubscriber mySubscriber) {
        RetrofitUtils.getApiObservable().queryBdInfo()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }


    /**
     * 获取掌柜App语音播报接收设置
     * @param mySubscriber
     */
    public static void queryAppVoiceSet(MySubscriber mySubscriber) {
        RetrofitUtils.getApiObservable().queryAppVoiceSet()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }

    /**
     * 设置语音播报各个类型开关设置
     * @param request_userSwitchSetting
     * @param mySubscriber
     */
    public static void doUserSwitchSetting(Request_userSwitchSetting request_userSwitchSetting,MySubscriber mySubscriber) {
        RetrofitUtils.getApiObservable().doUserSwitchSetting(request_userSwitchSetting)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }
    /**
     * 获取bd 信息
     * @param mySubscriber
     */
    public static void deviceQuery(Request_deviceQuery request_deviceQuery, MySubscriber mySubscriber) {
        RetrofitUtils.getApiObservable().deviceQuery(request_deviceQuery)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }

    /**
     * 设置语音播报相关的限制条件
     * @param mySubscriber
     */
    public static void doSwitchLimitationSetting(Request_switchLimitationSetting request_switchLimitationSetting,MySubscriber mySubscriber) {
        RetrofitUtils.getApiObservable().doSwitchLimitationSetting(request_switchLimitationSetting)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }

    /**
     * 门店列表设置,多选
     * @param request_shopList
     * @param mySubscriber
     */
    public static void  doAppVoiceShopListSet(Request_shopList request_shopList, MySubscriber mySubscriber){
        RetrofitUtils.getApiObservable().doAppVoiceShopListSet(request_shopList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }

    /**
     * 按照门店id查询码列表
     * @param request_shopList
     * @param mySubscriber
     */
    public static void  doQueryQrCodesByShopIdList(Request_deviceQuery request_shopList, MySubscriber mySubscriber){
        RetrofitUtils.getApiObservable().doQueryQrCodesByShopIdList(request_shopList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(mySubscriber);
    }
}
